package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.interceptor.JWTInterceptor;
import com.example.demo.result.Result;
import com.example.demo.result.ResultUtils;
import com.example.demo.service.UserService;
import com.example.demo.utils.JWTUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;


@RestController
public class Controller {

    @Resource UserService userService;
    @GetMapping("/test")
    public Result test(){
        return ResultUtils.success("芜湖");
    }
    @GetMapping("/user/login")
    public Result userlogin() {
        User u = new User();
        u.setId(1);
        u.setUsername("testUser");
        String token = JWTUtils.getToken(u);
        return ResultUtils.success(token);
    }
    @GetMapping("/user/add")
    public Result AddUser(){
        return userService.addUser();
    }
}
